# rules for builds
# contains the compiler and linker rules

# path
VPATH = ..\\..

# echo cancelation
ECHO =
# @

# the tools rules and flags
$TOOLROOT = c:\tornado2.2\host\x86-win32\bin
CC = $(ECHO)$(ROOT)ccmips
CFLAGS = -c
LD = $(ECHO)$(ROOT)ccmips
LFLAGS =
MAKEDEPEND = $(ECHO)$(ROOT)ccmips
MFLAGS = -MM
MOUT = >>

DEL = $(ECHO)del /F



#include all the modules and create the SRC macro
SRC :=
include $(patsubst %,..\\..\\%\\module.mak,$(MODULES))

# convert source list into obj list
OBJ = $(patsubst %.c,%.o,$(subst /,\,$(SRC)))

# include file driectories
INC = $(patsubst %,..\..\%\inc,$(subst /,\,$(subst /,\,$(MODULES))))

# rules
.PHONY : clean depend

all : exe\\$(BUILDNAME).out

exe\\$(BUILDNAME).out: $(OBJ) $(LIB) makefile $(patsubst %,..\\..\\%\\module.mak,$(MODULES))
	$(LD) $(LFLAGS) $(OBJ) $(LIB) -o $@

%.o : %.c
	$(CC) $(CFLAGS) $(patsubst %,-I%,$(INC)) $< -o $@

depend :
	@echo "# GENERATED FILE!" > depend.mak
	@echo >> depend.mak
	$(MAKEDEPEND) $(MFLAGS) $(patsubst %,-I%,$(INC)) $(SRC) $(MOUT)depend.mak

clean :
	$(DEL) $(OBJ)
	$(DEL) exe\*
